
//引入http模块
var socketio = require('socket.io'),
	fs 	= require('fs'),
	https     = require('http'),
	domain   = require('domain'),
	redis    = require('redis'),
    redisio  = require('socket.io-redis'),
    request  = require('request'),
    md5  = require('md5-node'),
    config   = require('./config.js');

var d = domain.create();

d.on("error", function(err) {
	//console.log(err);
});
 // var options = {
  //     key: fs.readFileSync('/usr/local/ssl/xxx.key'),
  //     cert: fs.readFileSync('/usr/local/ssl/xxx.crt')
    // }; 
//var numscount=0;// 在线人数统计
var sockets = {};
var chat_history={};
var chat_interval={};
/* 主播连麦关系 */
var LiveConnect={};
var LiveConnect_pull={};


// console.log(config['REDISPASS'])
// redis 链接
// var clientRedis  = redis.createClient(config['REDISPORT'],config['REDISHOST']);
// clientRedis.auth(config['REDISPASS']);


//var server = https.createServer(options,function(req, res) {
var server = https.createServer(function(req, res) {
	res.writeHead(200, {
		'Content-type': 'text/html;charset=utf-8'
	});
    
   //res.write("人数: " + numscount );
	res.end('服务开启'+config['socket_port']);
}).listen(config['socket_port'], function() {
	//console.log('服务开启19965');
});

var field=[];

// var io = socketio.listen(server,{
// 	pingTimeout: 60000,
//   	pingInterval: 25000
// });
// console.log(io)


var io = require('socket.io')(server);
//监听连接事件
io.on("connection",function(socket){ 
    console.log("1 个客户端连接了");
})
